package com.etime.shycourse.controller.accountonline;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etime.shycourse.config.PageMessage;
import com.etime.shycourse.dto.CourseSellConditionDto;
import com.etime.shycourse.dto.SettlementDto;
import com.etime.shycourse.services.account.interfaces.AccountStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * 结算统计模块（财务统计）
 */
@Api(tags = "后台-财务统计模块")
@RestController
@RequestMapping("/sys/account/statistics")
public class AccountStatisticsController {

    @Autowired
    private AccountStatisticsService accountStatisticsService;

    // 根据课程类型及时间段查询结算记录
    @ApiOperation("查询结算记录")
    @RequestMapping("listSettlement")
    public PageMessage<SettlementDto> selectAllSettlement(String settlementtype, String startDate, String endDate, String pagenum, String pagesize){
        Page<SettlementDto> page = accountStatisticsService.selectAllSettlement(settlementtype,startDate,endDate,pagenum,pagesize);
        PageMessage<SettlementDto> pageMessage = new PageMessage<>();
        pageMessage.setPagedata(page);
        return pageMessage;
    }

    @ApiOperation("查询结算记录明细")
    @RequestMapping("settlement")
    public PageMessage<SettlementDto> selectSettlementDetail(String settlementtype, String startDate, String endDate, String settlementuserid,String pagenum,String pagesize){
        Page<SettlementDto> page = accountStatisticsService.selectSettlementDetail(settlementtype,startDate,endDate,settlementuserid,pagenum,pagesize);
        PageMessage<SettlementDto> pageMessage = new PageMessage<>();
        pageMessage.setPagedata(page);
        return pageMessage;
    }


    @ApiOperation("查询课程销售情况")
    @RequestMapping("listCourse")
    public PageMessage<CourseSellConditionDto> selectAllCourse(String coursetypeid,String pagenum,String pagesize){
        PageMessage<CourseSellConditionDto> pageMessage = new PageMessage<>();
        Page<CourseSellConditionDto> page = accountStatisticsService.selectAllCourse(coursetypeid,pagenum,pagesize);
        pageMessage.setPagedata(page);
        return pageMessage;
    }


    @ApiOperation("查询课程销售明细")
    @RequestMapping("course")
    public PageMessage<SettlementDto> selectCourseDetail(String courseid,String pagenum,String pagesize){
        PageMessage<SettlementDto> pageMessage = new PageMessage<>();
        Page<SettlementDto> page = accountStatisticsService.selectCourseDetail(courseid,pagenum,pagesize);
        pageMessage.setPagedata(page);
        return pageMessage;
    }
}
